package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.entity.PageResult;
import com.woniu.pojo.PdaLoginLog;
import com.woniu.mapper.PdaLoginLogMapper;
import com.woniu.service.IPdaLoginLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.vo.MagnetLogReturnVo;
import com.woniu.vo.PdaLoginLogQueryVo;
import com.woniu.vo.PdaLoginLogReturnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author long
 * @since 2022-10-13
 */
@Service
public class PdaLoginLogServiceImpl extends ServiceImpl<PdaLoginLogMapper, PdaLoginLog> implements IPdaLoginLogService {
    @Autowired
    private PdaLoginLogMapper pdaLoginLogMapper;

    @Override
    public PageResult search(Integer currentPage, Integer pageSize, PdaLoginLogQueryVo pdaLoginLogQueryVo) {
        // 创建分页对象
        IPage iPage = new Page<>(currentPage, pageSize);
        // 构建查询对象
        /*QueryWrapper<Magnet> wrapper = new QueryWrapper<>();
        if(megnetReturnVo != null){
            if(!StringUtils.isEmpty(megnetReturnVo.getName())){
                wrapper.like("name", megnetReturnVo.getName());
            }
            if(megnetReturnVo.getId() != null){
                wrapper.eq("id", megnetReturnVo.getId());
            }
        }*/

        // 调用mapper进行分页查询
        IPage<PdaLoginLogReturnVo> magnetIPage = pdaLoginLogMapper.searchPageByPdaLoginLog(iPage, pdaLoginLogQueryVo);
        // 封装返回对象
        return new PageResult(magnetIPage.getTotal(), magnetIPage.getRecords());
    }
}
